import { defineComponent, onMounted, ref } from "vue";
import classes from "./index.module.less";
import { getSvg } from "./d3utils";

const D3Chart = defineComponent({
  name: "D3Chart",
  setup() {
    const wrap = ref<HTMLDivElement>();
    onMounted(() => {
      if (wrap.value) {
        let svg = getSvg();
        console.log(svg);
        if (svg) {
          wrap.value.innerHTML = "";
          wrap.value.appendChild(svg);
        }
      }
    });
    return () => <div ref={wrap} class={classes.wrap}></div>;
  },
});

export default D3Chart;
